# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import Union
from fastapi import Query
from pydantic import BaseModel, Field


class SquareCategorySearchIn(BaseModel):
    """ 广场分类搜索参数 """
    page_no: int = Query(default=1, gt=0, description="当前页码")
    page_size: int = Query(default=15, gt=0, le=200, description="每页条数")
    type: Union[str, None] = Query(default="robot", description="分类场景: [robot,draws,video,music]")
    name: Union[str, None] = Query(default="", description="分类名称")
    is_disable: Union[int, None] = Query(default=0, ge=0, le=1, description="是否禁用: [0=否, 1=是]")


class SquareCategoryDetailIn(BaseModel):
    """广场分类详情参数 """
    id: int = Query(..., gt=0, description="分类ID")


class SquareCategoryAddIn(BaseModel):
    """ 广场分类新增参数 """
    scene: str = Field(..., pattern=r"^(robot|draws|video|music)$", description="分类场景")
    name: str = Field(..., min_length=1, max_length=20, description="分类名称")
    sort: int = Field(default=0, ge=0, le=999999, description="排序编号")
    is_disable: int = Field(default=0, ge=0, le=1, description="是否禁用: [0=否, 1=是]")

    class Config:
        json_schema_extra = {
            "example": {
                "scene": "robot",
                "name": "工作学习",
                "sort": 0,
                "is_disable": 0
            }
        }


class SquareCategoryEditIn(BaseModel):
    """ 广场分类编辑参数 """
    id: int = Field(..., gt=0, description="分类ID")
    scene: str = Field(..., pattern=r"^(robot|draws|video|music)$", description="分类场景")
    name: str = Field(..., min_length=1, max_length=20, description="分类名称")
    icon: str = Field(max_length=250, description="分类图标")
    sort: int = Field(ge=0, le=999999, default=0, description="排序编号")
    is_disable: int = Field(ge=0, le=1, default=0, description="是否禁用: [0=否, 1=是]")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "scene": "robot",
                "name": "工作学习",
                "sort": 0,
                "is_disable": 0
            }
        }


class SquareCategoryDeleteIn(BaseModel):
    """ 广场分类删除参数 """
    id: int = Field(gt=0, description="广场分类ID", examples=[1])

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1
            }
        }


"""--------------- Separator ---------------"""


class SquareCategoryListVo(BaseModel):
    """ 广场分类列表Vo """
    id: int = Field(description="分类ID")
    scene: str = Field(description="分类场景")
    name: str = Field(description="分类名称")
    icon: str = Field(description="分类图标")
    nums: int = Field(default=0, description="元素数量")
    sort: int = Field(description="分类排序")
    is_disable: int = Field(description="是否禁用: [0=否, 1=是]")
    create_time: str = Field(description="创建时间")
    update_time: str = Field(description="更新时间")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "scene": "robot",
                "name": "工作学习",
                "sort": 0,
                "nums": 0,
                "is_disable": 0,
                "create_time": "2023-11-08 10:19:19",
                "update_time": "2024-06-30 17:35:24"
            }
        }


class SquareCategoryDetailVo(BaseModel):
    """ 广场分类详情Vo """
    id: int = Field(description="分类ID")
    scene: str = Field(description="分类场景")
    name: str = Field(description="分类名称")
    sort: int = Field(description="分类排序")
    is_disable: int = Field(description="是否禁用: [0=否, 1=是]")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "scene": "robot",
                "name": "工作学习",
                "sort": 0,
                "is_disable": 0,
            }
        }
